/**
 * @author caesar
 * @date 2025/7/2
 * @apiNote
 */
/*
将1到100的数字，按照如下规则进行打印：
1	2	3	4	5	6	7	8	9	10
36	37	38	39	40	41	42	43	44	11
35	64	65	66	67	68	69	70	45	12
34	63	84	85	86	87	88	71	46	13
33	62	83	96	97	98	89	72	47	14
32	61	82	95	100	99	90	73	48	15
31	60	81	94	93	92	91	74	49	16
30	59	80	79	78	77	76	75	50	17
29	58	57	56	55	54	53	52	51	18
28	27	26	25	24	23	22	21	20	19
*/
public class twoArrayPractice_4 {
    public static void main(String[] args) {
        int[][] arr = new int[10][10];
        int up = 0, down = arr.length-1, left = 0, right = arr[0].length-1;
        int start = 1;
        int end = arr.length * arr[0].length;
        while (start <= end) {
            //上
            for (int i = left; i <= right; i++) {
                arr[up][i] = start;
                start++;
            }
            //右
            for (int j = up+1; j <= down; j++) {
                arr[j][right] = start;
                start++;
            }
            // 下
            for (int i = right - 1; i >= left; i--) {
                arr[down][i] = start;
                start++;
            }
            // 左
            for (int i = down - 1; i >= up + 1; i--) {
                arr[i][left] = start;
                start++;
            }
            up++;
            down--;
            left++;
            right--;
        }
        for(int i = 0; i < arr.length; i++){
            for (int j = 0; j < arr[i].length; j++){
                System.out.print(arr[i][j] + "\t");
            }
            System.out.println();
        }
    }
}

